//
//  DisplayComputerCollectionCell.m
//  YIJU2.0-HD
//
//  Created by 陈柏兵 on 16/5/9.
//  Copyright © 2016年 张金国. All rights reserved.
//

#import "DisplayComputerCollectionCell.h"
#import "Masonry.h"
#import "Macro.h"

@implementation DisplayComputerCollectionCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor randomColor];
        [self setupConstraints];
    }
    return self;
}

- (void)setupConstraints {
    [self.computerImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top);
        make.left.equalTo(self.mas_left);
        make.width.equalTo(self.mas_width);
        make.height.equalTo(self.mas_height).multipliedBy(4/5.0f);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_computerImage.mas_bottom);
        make.left.equalTo(self.mas_left);
        make.width.equalTo(self.mas_width);
        make.height.equalTo(self.mas_height).multipliedBy(1/5.0f);
    }];
}

- (UIImageView *)computerImage {
    if (_computerImage == nil) {
        _computerImage = [[UIImageView alloc] init];
        _computerImage.backgroundColor = [UIColor clearColor];
        [self addSubview:_computerImage];
    }
    return _computerImage;
}

- (UILabel *)titleLabel {
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = TextFont14;
        _titleLabel.textColor = [UIColor lightGrayColor];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_titleLabel];
    }
    return _titleLabel;
}


@end
